home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.10 Oct 90 / NewToolBox.π / CDoMenu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-07  |  2.9 KB  |  150 lines  |  [TEXT/KAHL]

  1. /*
  2.  --------------- D O   M E N U 
  3.  
  4.                  May 1989 - HA OLIVER
  5. */
  6.  
  7.  
  8. #include "Demo.h"
  9.  
  10. extern  MenuHandle     myMenus[LastMenu];
  11. extern  Boolean        notFinished,isDoc;
  12. extern    TEHandle    CurrentText;
  13. extern    ListHandle    CurrentList;
  14. extern    WindowPtr    CurrentPort;
  15.  
  16. extern    pascal void    MyWindow(),MyControl();
  17.  
  18.  
  19. /*
  20. ---------------------- Menu choice.
  21. */
  22.  
  23. doMenu(result)
  24. long        result;
  25. {
  26.             int            theItem,theMenu;
  27.             Str255        name;
  28.     
  29.     theMenu=HiWord(result);
  30.     theItem=LoWord(result);
  31.     switch(theMenu)
  32.         {
  33.             case AppleM    :switch(theItem)
  34.                             {
  35.                                 case    AboutCom:break;
  36.                                 default          :GetItem(myMenus[1],theItem,&name);
  37.                                                        OpenDeskAcc(&name);break;
  38.                             }
  39.                          break;
  40.                           
  41.             case FileM    :switch(theItem)
  42.                             {
  43.                                 case     Example1    :doExample1();break;
  44.                                 case     Example2    :doExample2();break;
  45.                                 case     Example3    :doExample3();break;
  46.                                 case     Example4    :doExample4();break;
  47.                                 case     Example5    :doExample5();break;
  48.                                 case     QuitCom    :notFinished=FALSE;break;
  49.                             }
  50.                           break;    
  51.         }
  52.     HiliteMenu(0);
  53. }
  54.  
  55. /*
  56. ---------------------- Example1
  57. */
  58.  
  59. doExample1()
  60.     {
  61.         WindowPtr    theWindow;
  62.         OSErr        err;
  63.         
  64.         err    =InstalWindow(&theWindow,16001,MyWindow,false);
  65.         if (err==0)
  66.             {
  67.                 err    =InstalText(6001,theWindow);
  68.                 err    =InstalText(6002,theWindow);
  69.                 err    =InstalList(7001,theWindow);
  70.                 err    =InstalPict(8002,theWindow);
  71.                 DisableItem(myMenus[2],1);
  72.                 SetWTitle(theWindow,"\pExample #1");
  73.                 ShowWindow(theWindow);
  74.                 isDoc=true;
  75.             }
  76.     }
  77.  
  78.  doExample2()
  79.     {
  80.         WindowPtr    theWindow;
  81.         OSErr        err;
  82.         
  83.         err    =InstalWindow(&theWindow,16002,MyWindow,false);
  84.         if (err==0)
  85.           {
  86.             err    =InstalText(6003,theWindow);
  87.             err    =InstalList(7002,theWindow);
  88.             err    =InstalPict(8001,theWindow);
  89.             DisableItem(myMenus[2],2);
  90.             SetWTitle(theWindow,"\pExample #2");
  91.             ShowWindow(theWindow);
  92.             isDoc=true;
  93.           }
  94.     }
  95.  
  96. doExample3()
  97.     {
  98.         WindowPtr    theWindow;
  99.         OSErr        err;
  100.         
  101.         err    =InstalWindow(&theWindow,16003,MyWindow,false);
  102.         if (err==0)
  103.           {
  104.             err    =InstalPict(8003,theWindow);
  105.             DisableItem(myMenus[2],3);
  106.             SetWTitle(theWindow,"\pExample #3");
  107.             ShowWindow(theWindow);
  108.             isDoc=true;
  109.           }
  110.     }
  111.     
  112. doExample4()
  113.     {
  114.         WindowPtr    theWindow;
  115.         OSErr        err;
  116.         
  117.         err    =InstalWindow(&theWindow,16004,MyWindow,false);
  118.         if (err==0)
  119.           {
  120.             err    =InstalList(7003,theWindow);
  121.             err    =InstalControl(8001,MyControl,theWindow);
  122.             err    =InstalControl(8002,MyControl,theWindow);
  123.             err    =InstalControl(8003,MyControl,theWindow);
  124.             DisableItem(myMenus[2],4);
  125.             SetWTitle(theWindow,"\pExample #4");
  126.             ShowWindow(theWindow);
  127.             isDoc=true;
  128.           }
  129.     }
  130.  
  131.  doExample5()
  132.     {
  133.         WindowPtr    theWindow;
  134.         OSErr        err;
  135.         
  136.         err    =InstalWindow(&theWindow,16005,MyWindow,false);
  137.         if (err==0)
  138.           {
  139.             err    =InstalList(7004,theWindow);
  140.             err    =InstalList(7003,theWindow);
  141.             DisableItem(myMenus[2],5);
  142.             SetWTitle(theWindow,"\pExample #5");
  143.             ShowWindow(theWindow);
  144.             isDoc=true;
  145.           }
  146.     }
  147. /*
  148. ----------------------
  149. */
  150.